package com.itcast.myrpc.encoder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @program: bio_tcp
 * @description: 编码器, 抽象类实现MessageToByteEncoder ,
 * 实现了它实现了ChannelOutboundHandler接⼝，本质上也是
 * ChannelHandler。
 * @author: zhanghz001
 * @create: 2021-02-22 18:09
 **/
public class IntegerToByteBufEncoder extends MessageToByteEncoder<Integer> {
    
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext,
                          Integer integer, ByteBuf byteBuf) throws Exception {
        byteBuf.writeInt(integer);
    }
    
}
